Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2507 +/- ##
==========================================
- Coverage 80.96% 80.93% -0.04%
==========================================
Files 42 42
Lines 33359 33481 +122
Branches 33359 33481 +122
==========================================
+ Hits 27009 27097 +88
- Misses 2790 2799 +9
- Partials 3560 3585 +25 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| XmlNamespaceDefinition, XmlPassingArgument, XmlPassingClause, XmlTableColumn, | ||
| XmlTableColumnOption, |
There was a problem hiding this comment.
You should export the new enum next to XmlPassingArgument.
| XmlNamespaceDefinition, XmlPassingArgument, XmlPassingClause, XmlPassingMechanism, | |
| XmlTableColumn, XmlTableColumnOption, |
There was a problem hiding this comment.
You should consume BY only together with REF or VALUE, as a lone BY is currently dropped, so XMLEXISTS('/a' PASSING '<a/>' BY) parses and renders without it, while PostgreSQL rejects it.
| let mechanism = self.parse_optional_xml_passing_mechanism(); | |
| let expr = self.parse_expr()?; | |
| let alias = if self.parse_keyword(Keyword::AS) { | |
| Some(self.parse_identifier()?) | |
| } else { | |
| None | |
| }; | |
| let trailing_mechanism = self.parse_optional_xml_passing_mechanism(); | |
| arguments.push(XmlPassingArgument { | |
| expr, | |
| alias, | |
| mechanism, | |
| trailing_mechanism, | |
| }); | |
| if !self.consume_token(&Token::Comma) { | |
| break; | |
| } | |
| } | |
| } | |
| Ok(XmlPassingClause { arguments }) | |
| } | |
| fn parse_optional_xml_passing_mechanism(&mut self) -> Option<XmlPassingMechanism> { | |
| if self.parse_keywords(&[Keyword::BY, Keyword::REF]) { | |
| Some(XmlPassingMechanism::ByRef) | |
| } else if self.parse_keywords(&[Keyword::BY, Keyword::VALUE]) { | |
| Some(XmlPassingMechanism::ByValue) | |
| } else { | |
| None | |
| } | |
| } |
| /// Parse the argument list of `XMLEXISTS(text PASSING [BY {REF|VALUE}] xml [BY {REF|VALUE}])`. | ||
| fn parse_xmlexists_argument_list(&mut self) -> Result<FunctionArgumentList, ParserError> { | ||
| let xpath_expr = self.parse_expr()?; | ||
| let passing = self.parse_xml_passing_clause()?; |
There was a problem hiding this comment.
You should require PASSING, which parse_xml_passing_clause treats as optional. SELECT XMLEXISTS('/a') currently parses and renders as SELECT XMLEXISTS('/a' ), while PostgreSQL rejects it.
| let passing = self.parse_xml_passing_clause()?; | |
| if !self.peek_keyword(Keyword::PASSING) { | |
| return self.expected_ref("PASSING", self.peek_token_ref()); | |
| } | |
| let passing = self.parse_xml_passing_clause()?; |
| dialects.verified_stmt("SELECT XMLSERIALIZE(DOCUMENT '<a/>'::xml AS TEXT NO INDENT)"); | ||
| dialects.verified_stmt("SELECT XMLEXISTS('/a' PASSING BY REF '<a/>')"); | ||
| dialects.verified_stmt("SELECT XMLEXISTS('/a' PASSING '<a/>')"); | ||
| dialects.verified_stmt("SELECT XMLEXISTS('/a' PASSING BY VALUE '<a/>')"); |
There was a problem hiding this comment.
These are the red tests I found and mentioned in the other notes.
| dialects.verified_stmt("SELECT XMLEXISTS('/a' PASSING BY VALUE '<a/>')"); | |
| dialects.verified_stmt("SELECT XMLEXISTS('/a' PASSING BY VALUE '<a/>')"); | |
| dialects.verified_stmt("SELECT XMLEXISTS('/a' PASSING BY VALUE '<a/>' BY REF)"); | |
| for sql in [ | |
| "SELECT XMLEXISTS('/a')", | |
| "SELECT XMLEXISTS('/a' PASSING '<a/>' BY)", | |
| ] { | |
| assert!(dialects.parse_sql_statements(sql).is_err(), "{sql}"); | |
| } |
Adds support for PostgreSQL XML function syntaxes:
XMLELEMENT(NAME name [, XMLATTRIBUTES(...) ] [, content [, ...]])XMLPI(NAME name [, content ])XMLROOT(xml, VERSION {text | NO VALUE} [, STANDALONE {YES | NO | NO VALUE} ])XMLSERIALIZE({ DOCUMENT | CONTENT } value AS type [ [ NO ] INDENT ])XMLEXISTS(text PASSING [BY {REF|VALUE}] xml [BY {REF|VALUE}])Example
Docs:
AI Assistance: Code authored and validated with GitHub Copilot.